﻿using System;
using System.Xml;
using Assist;
using Autodesk.Revit.DB;

namespace HYOpeningCommon.OpeningProfile
{
	public class OpeningProfileEquipRect : OpeningProfileBase
	{
		public override string GetCutSize(bool bIsFeet)
		{
			double val = this.m_dWidth;
			double val2 = this.m_dHeight;
			double val3 = this.m_dThickness;
			if (!bIsFeet)
			{
				val = AssistFunc.feetToMM(val);
				val2 = AssistFunc.feetToMM(val2);
				val3 = AssistFunc.feetToMM(val3);
			}
			return string.Concat(new string[]
			{
				val2.ToString("f0"),
				"X",
				val.ToString("f0"),
				"X",
				val3.ToString("f0")
			});
		}

		public override string GetOpeningSize(bool bIsFeet)
		{
			double val = this.m_dWidth + this.m_dExtendDist * 2.0;
			double val2 = this.m_dHeight + this.m_dExtendDist * 2.0;
			double val3 = this.m_dPenetrationThickness;
			if (!bIsFeet)
			{
				val = AssistFunc.feetToMM(val);
				val2 = AssistFunc.feetToMM(val2);
				val3 = AssistFunc.feetToMM(val3);
			}
			return string.Concat(new string[]
			{
				val2.ToString("f0"),
				"X",
				val.ToString("f0"),
				"X",
				val3.ToString("f0")
			});
		}

		public override bool Export2XmlNode(XmlElement xmlNode)
		{
			try
			{
				if (!base.Export2XmlNode(xmlNode))
				{
					return false;
				}
				xmlNode.SetAttribute("CutHeight", this.m_dHeight.ToString());
				xmlNode.SetAttribute("CutThickness", this.m_dThickness.ToString());
				xmlNode.SetAttribute("CutWidth", this.m_dWidth.ToString());
			}
			catch
			{
				return false;
			}
			return true;
		}

		public override bool ImportByXmlNode(XmlNode xmlNode)
		{
			try
			{
				if (!base.ImportByXmlNode(xmlNode))
				{
					return false;
				}
				this.m_dHeight = Convert.ToDouble(xmlNode.Attributes["CutHeight"].Value);
				this.m_dThickness = Convert.ToDouble(xmlNode.Attributes["CutThickness"].Value);
				this.m_dWidth = Convert.ToDouble(xmlNode.Attributes["CutWidth"].Value);
			}
			catch
			{
				return false;
			}
			return true;
		}

		public override Outline GetSectionOutline3D()
		{
			return base.GetSectionOutline3D();
		}

		public double m_dHeight;

		public double m_dThickness;

		public double m_dWidth;
	}
}
